import React ,{useState} from 'react'
import { Card, Form, Input, InputNumber, Button } from "antd";
import { addAPI } from "../service/auth";


const layout = {
  labelCol: {
    span: 8,
  },
  wrapperCol: {
    span: 16,
  },
};






const validateMessages = {
  required: '${label}不能为空!',

  number: {
    range: '${label} 次数 ${min} ~ ${max}',
  },
};

export default function Join() {
  
 
  const onFinish = (values) => {
    console.log(values);
    addAPI({ ...values.user }).then(res => {
      console.log(res)
      
    })
  };
  const onFinishFailed = (errorInfo) => {
    console.log('Failed:', errorInfo);
  };
  return (

    <Card title="添加客户">
      <Form {...layout} name="nest-messages" onFinish={onFinish}
      onFinishFailed={onFinishFailed} validateMessages={validateMessages}>
        <Form.Item
          name={['user', 'name']}
          label="姓名"
          rules={[
            {
              required: true,
            },
          ]}
        >
          <Input />
        </Form.Item>
        <Form.Item
          name={['user', 'price']}
          label="电话"
          rules={[
            {
              required: true,
              message: '电话不能为空',
            },
          ]}
        >
          <Input />
        </Form.Item>
        <Form.Item
          name={['user', 'descriptions']}
          label="住址"
          rules={[
            {
              required: true,
              message: '地址不能为空',
            },
          ]}
        >
          <Input />
        </Form.Item>
        <Form.Item name={['user', 'content']} label="品类">
          <Input />
        </Form.Item>
        <Form.Item
          name={['user', 'coverImg']}
          label="来访"
          rules={[
            {
              type: 'number',
              min: 0,
              max: 99,
            },
          ]}
        >
          <InputNumber />
        </Form.Item>

        <Form.Item name={['user', 'waiter']} label="接待">
          <Input />
        </Form.Item>
        <Form.Item wrapperCol={{ ...layout.wrapperCol, offset: 8 }}>
          <Button type="primary" htmlType="submit">
            提交
        </Button>
        </Form.Item>
      </Form>

    </Card>


  )
}
